package com.newmainsoftech.ant.script;

import org.apache.tools.ant.types.LogLevel;

public abstract class AntrunScriptUtilTemplate implements AntOwnerAccessorContract, AntLogMethodsContract {
	private AntOwnerAccessorImpl antOwnerAccessorImpl = new AntOwnerAccessorImpl();
		synchronized AntOwnerAccessorImpl getAntOwnerAccessorImpl() {
			return antOwnerAccessorImpl;
		}
		protected synchronized void setAntOwnerAccessorImpl( AntOwnerAccessorImpl antOwnerAccessorImpl) {
			this.antOwnerAccessorImpl = antOwnerAccessorImpl;
		}
		
	// Regarding AntOwnerAccessorContract interface -----------------------------------------------
	public OwnerRace getOwnerRace() {
		AntOwnerAccessorImpl antOwnerAccessor = getAntOwnerAccessorImpl();
		if ( antOwnerAccessor == null) return null;
		return antOwnerAccessor.getOwnerRace();
	}
	public Object getOwner() {
		AntOwnerAccessorImpl antOwnerAccessor = getAntOwnerAccessorImpl();
		if ( antOwnerAccessor == null) return null;
		return antOwnerAccessor.getOwner();
	}
	public synchronized void setOwner( Object owner) {
		AntOwnerAccessorImpl antOwnerAccessorImplObj = getAntOwnerAccessorImpl();
		if ( antOwnerAccessorImplObj == null) {
			antOwnerAccessorImplObj = new AntOwnerAccessorImpl();
			setAntOwnerAccessorImpl( antOwnerAccessorImplObj);
		}
		antOwnerAccessorImplObj.setOwner( owner);
	}
	// --------------------------------------------------------------------------------------------
	// Regarding AntLogMethodsContract interface --------------------------------------------------
	public void log( String msg) {
		AntOwnerAccessorImpl antOwnerAccessorImplObj = getAntOwnerAccessorImpl();
		if ( antOwnerAccessorImplObj != null) {
			antOwnerAccessorImplObj.log( msg);
		}
	}
	public void log( String msg, int logLevel) {
		AntOwnerAccessorImpl antOwnerAccessorImplObj = getAntOwnerAccessorImpl();
		if ( antOwnerAccessorImplObj != null) {
			antOwnerAccessorImplObj.log( msg, logLevel);
		}
	}
	public void log( String msg, LogLevel logLevel) {
		if ( logLevel != null) log( msg, logLevel.getLevel());
	}
	// --------------------------------------------------------------------------------------------
}
